import { Column, Index, PrimaryGeneratedColumn } from "typeorm";
import { EntityModel } from "@midwayjs/orm";

@Index("email", ["email"], { unique: true })
@EntityModel("admins", { schema: "heart_neighbor" })
export class Admins {
  @PrimaryGeneratedColumn({
    type: "bigint",
    name: "id",
    comment: "管理员ID",
    unsigned: true,
  })
  id!: string;

  @Column("varchar", { name: "name", comment: "姓名", length: 100 })
  name: string = '';

  @Column("char", {
    name: "gender",
    nullable: true,
    comment: "性别，M=男，F=女",
    length: 1,
  })
  gender!: string | null;

  @Column("varchar", {
    name: "email",
    unique: true,
    comment: "邮箱",
    length: 100,
  })
  email!: string;

  @Column("int", {
    name: "age",
    nullable: true,
    comment: "年龄",
    unsigned: true,
  })
  age!: number | null;

  @Column("tinyint", {
    name: "is_enabled",
    comment: "是否启用，0=禁用，1=启用",
    width: 1,
    default: () => "'1'",
  })
  isEnabled!: boolean;

  @Column("timestamp", {
    name: "created_at",
    comment: "记录创建时间",
    default: () => "CURRENT_TIMESTAMP",
  })
  createdAt!: Date;

  @Column("varchar", {
    name: "password",
    nullable: true,
    comment: "密码",
    length: 255,
  })
  password!: string | null;

  @Column("varchar", {
    name: "phone",
    nullable: true,
    comment: "电话",
    length: 255,
  })
  phone!: string | null;
}
